package com.infocollect.project.api.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.infocollect.project.api.entity.TappRoleEntity;
import com.infocollect.project.api.mapper.TappRoleMapper;
import com.infocollect.project.api.service.ITappRoleService;
import com.infocollect.project.api.vo.RoleUserVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (TappRole)表服务实现类
 *
 * @author makejava
 * @since 2019-12-25 10:32:31
 */
@Service("tappRoleService")
public class TappRoleServiceImpl extends ServiceImpl<TappRoleMapper, TappRoleEntity> implements ITappRoleService {


    /**
     * 通过ID查询单条数据
     *
     * @param fid 主键
     * @return 实例对象
     */
    @Override
    public TappRoleEntity queryById(Long fid) {
        return this.baseMapper.selectById(fid);
    }



    /**
     * 新增数据
     *
     * @param tappRole 实例对象
     * @return 实例对象
     */
    @Override
    public TappRoleEntity insert(TappRoleEntity tappRole) {
        this.baseMapper.insert(tappRole);
        return tappRole;
    }

    /**
     * 修改数据
     *
     * @param tappRole 实例对象
     * @return 实例对象
     */
    @Override
    public TappRoleEntity update(TappRoleEntity tappRole) {
        this.baseMapper.updateById(tappRole);
        return this.queryById(tappRole.getFid());
    }

    /**
     * 通过主键删除数据
     *
     * @param fid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long fid) {
        return this.baseMapper.deleteById(fid) > 0;
    }

    /**
     * 查询多条数据
     * @menu 根据实体对象是否有值 进行查询
     * @return 对象列表
     */
    @Override
    public List<TappRoleEntity> queryAll(TappRoleEntity entity){
        return this.baseMapper.queryAll(entity) ;
    }


    /**
     * 查询角色成员
     *
     * @param
     * @return 对象列表
     */
    @Override
    public  List<RoleUserVO> getRoleMember(RoleUserVO roleUser){
        return this.baseMapper.getRoleUser(roleUser) ;

    }

    /**
     * 通过实体作为筛选条件查询
     *
     * @param
     * @return 对象列表
     */
    @Override
    public  List<RoleUserVO> getUserByRole(RoleUserVO roleUser){
        return this.baseMapper.getUserByRole(roleUser) ;
    }
}